# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkiotda.v5.region.iotda_region import IoTDARegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkiotda.v5 import *

if __name__ == "__main__":
    ak = "akakak换自己的akakakaka"
    sk = "sksksk换自己的ksksksksksksksksksksksksksk"
    
    credentials = BasicCredentials(ak, sk) \

    client = IoTDAClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(IoTDARegion.value_of("cn-north-4")) \
        .build()

    try:
        request = CreateCommandRequest()
        request.device_id = "6****************7_qysz_1"


##        paras={"Light":"OFF"},
        request.body = DeviceCommandRequest(
            paras={'Light':'ON'},
            command_name="Agriculture_Control_light",
            service_id="Agriculture"
        )
        response = client.create_command(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)



